cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

project(recipe-02 LANGUAGES C)

# 使用C99标准
set(CMAKE_CXX_STANDARD 99)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_STANDARD_REQUIRED ON)

# 先找到一个Python解释器
find_package(PythonInterp REQUIRED)
# PythonLibs找到Python头文件和库的模块
find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT REQUIRED)                # 匹配的相应Python版本的包括文件和库

add_executable(hello-embedded-python hello-embedded-python.c)

# 可执行文件包含 Python.h 头文件。因此，这个目标的 include 目录必须包含Python 的 include 目录
target_include_directories(hello-embedded-python PRIVATE ${PYTHON_INCLUDE_DIRS})
# 将可执行文件链接到Python库，通过 PYTHON_LIBRARIES
target_link_libraries(hello-embedded-python PRIVATE ${PYTHON_LIBRARIES})
